<div>
    <button class="layui-btn" style="margin-left: 20px" id="isCheckFun">确认选择</button>
</div>
<table id="itemTable"></table>
<script>
    layui.use(['layer', 'form', 'table', 'admin', 'upload', 'tree', 'laytpl'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var config = layui.config;
        var admin = layui.admin;
        var upload = layui.upload;
        var laytpl = layui.laytpl;
        const id = parentData.id
        let cacheList = parentData.cacheList
        if (id) {
            table.render({
                elem: '#itemTable',
                url: config.base + `enterprise/sell/admin/customerProductCatalog/list?limit=9999&customerId=${id}`,
                // where: {purchaseDeliveryRecordId: id},
                page: true,
                cellMinWidth: 100,
                cols: [[
                    {type: 'checkbox', fixed: 'left'}
                    , {type: 'numbers', title: '序号'}
                    , {field: 'cusSkuCode', align: 'center', title: '客户物料料号编码', width: 150}
                    , {field: 'cusProductName', align: 'center', title: '客户物料名称', width: 140}
                    , {field: 'cusProductSpec', align: 'center', title: '客户规格码', width: 140}
                    , {field: 'attachmentName', align: 'center', title: '附件'}
                    , {field: 'productCategoryName', align: 'center', title: '内部物料类型', width: 140}
                    , {field: 'skuCode', align: 'center', title: '内部物料规格码', width: 140}
                    , {field: 'unitName', align: 'center', title: '主计量单位'}
                    , {field: 'remark', align: 'center', title: '备注'}
                ]],
                done: function () {
                    if (parentData.cacheList.length > 0) {
                        table.cache['itemTable'].forEach((item, index) => {
                            const isSelected = parentData.cacheList.some(checkItem => checkItem.id === item.id);
                            if (isSelected) {
                                item["LAY_CHECKED"] = true
                                $('div.layui-table-body input[name="layTableCheckbox"]:eq(' + (index) + ')').prop('checked', true);
                                $('div.layui-table-body input[name="layTableCheckbox"]:eq(' + (index) + ')').next().addClass('layui-form-checked');
                            }
                        });
                    }
                    console.log(table.cache['itemTable'])
                    form.render('checkbox');
                }
            });

            $('#isCheckFun').click(() => {
                var checkStatus = table.checkStatus('itemTable'); // 'demo'是表格的ID
                var data = checkStatus.data;  // 选中的数据
                if (typeof parent.layui !== 'undefined') {
                    childData.list = data
                    console.log('childData', data)
                    layer.close(parentData.zindex); // 关闭指定的弹窗
                }
            })
        }

    })
</script>